package esya;

import java.sql.SQLException;

import junit.framework.*;

public class Testing extends TestCase{
	
	public void testNameQuery() throws ClassNotFoundException, SQLException{
		
		createDb d=new createDb();
		d.createDB();
		Query q=new Query();
		
		assertEquals(" event_name: Stratagem date: 3Sep11 time: 1400 venue: CR4&CR5",q.nameQuery("Stratagem"));
		assertEquals(" event_name: Stratagem date: 3Sep11 time: 1400 venue: CR4&CR5",q.nameQuery("Stockmarket"));
		assertEquals("Invalid input. Please check and try again.",q.nameQuery("Stratag"));
		assertEquals("Invalid input. Please check and try again.",q.nameQuery(""));
	
	}
	
	public void testDateQuery() throws ClassNotFoundException, SQLException{
		
		createDb d=new createDb();
		d.createDB();
		Query q=new Query();
	
		assertEquals(" event_name: Pwned date: 3Sep11 time: 1700 venue: CR5 event_name: Stratagem date: 3Sep11 time: 1400 venue: CR4&CR5",q.dateQuery("3Sep"));
		assertEquals("Sorry, no event on this date",q.dateQuery("5Oct"));
		assertEquals("Sorry, no event on this date",q.dateQuery("23/01"));
	}
	
	public void testVenueQuery() throws SQLException, ClassNotFoundException{
		
		createDb d=new createDb();
		d.createDB();
		Query q=new Query();
		assertEquals(" event_name: Stratagem date: 3Sep11 time: 1400 venue: CR4&CR5",q.venueQuery("CR4"));
		assertEquals(" event_name: Pwned date: 3Sep11 time: 1700 venue: CR5 event_name: Stratagem date: 3Sep11 time: 1400 venue: CR4&CR5",q.venueQuery("CR5"));
		assertEquals("Sorry, no event at this venue",q.venueQuery("ground"));
	
	}
	
	public void testTimeQuery() throws ClassNotFoundException, SQLException{
	
		createDb d=new createDb();
		d.createDB();
		Query q=new Query();
		
		//assertEquals(" event_name: Stratagem date: 3Sep11 time: 1400 venue: CR4&CR5",q.timeQuery("1400"));
		assertEquals("Sorry, no event at this time today",q.timeQuery("1234"));
	
	}
	
	

}
